package com.game.element
{
	import com.game.BaseBuff;
	import com.interfaces.tool.CommonUtil;
	
	import flash.utils.getTimer;
	
	public class SpeedBuff extends BaseBuff
	{
		public function SpeedBuff()
		{
			super();
			longTime = 3*1000;
		}
		
		override public function useing(baseElement:BaseElement):void{
			startTime = getTimer();
			baseElement.allBuffList.push(this);
			if(baseElement is PlayerElement){
				PlayerElement(baseElement).addSpeed = PlayerElement(baseElement).speed;
			}
			this.baseElement = baseElement;
		}
		
		override public function exce():void {
			if(startTime ==0){
				return;
			}
			if(getTimer() > startTime+longTime){
				for each(var key:* in baseElement.allBuffList){
					var baseBuff:BaseBuff = baseElement.allBuffList[key];
					if(baseBuff == this){
						CommonUtil.delFromArr(key, baseElement.allBuffList);
						break;
					}
				}
				
				if(baseElement is PlayerElement){
					PlayerElement(baseElement).addSpeed = 0;
				}
				dispose();
			}
		}
	}
}